﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace Alerts_Administration_2010.classes.views.templates
{
    public class AlertTemplateFilterTemplate : AlertViewTemplateBase
    {
        private RadioButtonList _rbl;

        protected override System.Web.UI.Control CreateControl()
        {
            _rbl = new RadioButtonList();
            return _rbl;
        }

        protected override string GetBoundPropertyNames()
        {
            return "Filter";
        }

        protected override object GetValue(string p)
        {
            return _rbl.SelectedValue;
        }

        protected override void BindControl(DetailsViewItemBLL boundItem)
        {
            foreach (string filter in boundItem.TemplateFilters.Keys)
            {
                var li = new ListItem(boundItem.TemplateFilters[filter]);
                li.Value = filter;
                if (li.Value == boundItem.Filter) li.Selected = true;
                _rbl.Items.Add(li);
            }
        }
    }
}
